<?php

//include_once('../../core/Model.php');

class seller_mdl extends Model
{
	public static $seller_table = "mac_seller";


	public function add_seller(
		$tb_uid,
		$tb_nick,
		$top_session,
		$last_name){
		$seller = $this->get_tb_seller($tb_uid);
		if(empty($seller['id'])){
			$this->dbh->insert(self::$seller_table,
				array(
					'tb_uid'=>$tb_uid,
					'tb_nick'=>$tb_nick,
					'top_session'=>$top_session,
					'last_name'=>$last_name
				)
			);
			$seller_id = $this->dbh->insert_id();
		}else{
			$this->dbh->update(self::$seller_table,
				array(
					'last_name'=>$last_name,
					'top_session'=>$top_session,
					'last_login'=>date('Y-m-d H:i:s')
				),
				'id='.$seller['id']
			);
		}
		$seller = $this->get_tb_seller($tb_uid);
		return $seller;
	}

	public function get_tb_seller($tb_uid){
		$r = '';
		if(!empty($tb_uid)){
			$sql = 'SELECT *
					FROM '.self::$seller_table.'
					WHERE tb_uid = '.$tb_uid;
			$r = $this->dbh->get_one($sql);
		}
		return $r;
	}

}